package com.axend.lib_base.view;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.util.AttributeSet;
import android.view.View;

public class CircleView extends View {

    private Paint paint;
    private int centerX;
    private int centerY;
    private int radius;
    private float scale;
    private int y16W;
    private int y16H;

    public CircleView(Context context) {
        super(context);
        init();
    }

    public CircleView(Context context, AttributeSet attrs) {
        super(context, attrs);
        init();
    }

    public CircleView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        init();
    }

    private void init() {
        paint = new Paint();
        paint.setColor(Color.GREEN); // 设置圆的颜色
        paint.setStyle(Paint.Style.STROKE); // 设置为描边样式
        paint.setStrokeWidth(5); // 设置描边宽度
//        paint.setAntiAlias(true); // 抗锯齿
    }

    public void setCircleProperties(int centerX, int centerY, int radius, float scale, int y16W, int y16H) {
        this.centerX = centerX;
        this.centerY = centerY;
        this.radius = radius;
        this.scale = scale;
        this.y16W = y16W;
        this.y16H = y16H;
        invalidate(); // 重新绘制
    }


    @Override
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);
        int scaledCenterX = (int) (centerX * scale);
        int scaledCenterY = (int) (centerY * scale);
        int scaledRadius = (int) (radius * scale);

        // 绘制圆形区域
        canvas.drawCircle(scaledCenterX, scaledCenterY, scaledRadius, paint);
    }
}
